import 'package:aio/aio.dart';
import 'package:flutter/cupertino.dart';
import 'package:app/src/http/bean/works_2023/purcontract_bean.dart';

import '../../../../generated/app_strings.dart';
import '../worksdo/material_requisition_bean.dart';
import '../wroks/contract_paymenttermscopy.dart';

///运输合同审核
class LogisticsContractBean extends BaseBean {
  ContractPaymentTerms? Cptc = null; //付款方式
  List<FileInfoBean>? FileInfo = null; //附件
  List<String>? getFileInfo() {
    if (FileInfo != null && FileInfo!.length > 0) {
      List<String> list = [];
      FileInfo?.forEach((element) {
        if (StringUtils.isNotEmpty(element.FilePatch)) {
          list.add(element.FilePatch!);
        }
      });
      return list;
    }
    return null;
  }

  String? PriceUnitName = ""; //货币
  String? CompanyName = ""; //采购公司
  String? CompanyBankName = ""; //开户行
  String? CarrierName="";//承运商
  String? TaxcodeName="";//税码

  String? PaymentTerms="";
  String? AdvancePercent="";
  String? Advance="";
  String? MinimumBalanceB="";
  String? MinimumBalanceA="";
  String? MidYearMonth="";
  String? MidYearDay="";
  String? MidYearPercent="";
  String? MidAccountMonth="";
  String? MidAccountDay="";
  String? EndYearMonth="";
  String? EndYearDay="";
  String? EndYearPercent="";
  String? EndAccountMonth="";
  String? EndAccountDay="";
  String? EndPayDay="";
  String? DatePay="";
  String? ReconciliationDate="";
  String? MaxPay="";
  String? PaymentPercent="";
  String? BeforeMonth="";
  ///审核日志
  List<WFLog>? WFLogList = null;
  ///运输线路车辆信息
  List<logisticsContractListBean>? logisticsContractList=null;
  String? IsSave="";
  String? deletedLogisticsContractListId="";
  String? deletedFileListId="";
  String? Id="";
  String? LContractCode="";//运输合同号
  String? LOutCode="";//运输合同外部编号
  String? CarrierId="";
  String? TransportType="";//运输方式
  ///获取运输方式
  String getTransportTypeName(BuildContext context) {
    if (TransportType == "1") {
      return AppStrings.of(context).TransportType1; //陆运
    } else if (TransportType == "2") {
      return AppStrings.of(context).TransportType2; //空运
    }
    return TransportType ?? "";
  }
  String? CreaterDateTime="";//创建时间 2023-05-06T00:00:00
  ///获取创建时间；只取年月日部分。
  String? getCreaterDateTime() {
    if (StringUtils.isNotEmpty(CreaterDateTime)) {
      if (CreaterDateTime!.contains("T")) {
        return CreaterDateTime!.split("T")[0];
      } else {
        return CreaterDateTime!.split(" ")[0];
      }
    }
    return CreaterDateTime;
  }
  String? PriceUnit="";
  String? LinkMan="";//联系人
  String? Telephone="";//联系电话
  String? Address="";//联系地址
  String? Email="";//邮箱
  String? IsTax="";
  String? SuperelevationTaxRate="";//结算税率
  String? SealType="";
  String? StatementDate="";//对账时间
  String? getStatementDate() {
    if (StringUtils.isNotEmpty(StatementDate)) {
      if (StatementDate!.contains("T")) {
        return StatementDate!.split("T")[0];
      } else {
        return StatementDate!.split(" ")[0];
      }
    }
    return StatementDate;
  }
  String? Status="";
  String? creater="";//创建人
  String? createrName="";//创建人
  String? Scrapcompensation="";
  String? MaterialType="";//物料类型
  ///获取物料类型名称
  String getMaterialTypeName(BuildContext context) {
    if (MaterialType == "MT01") {
      return AppStrings.of(context).Raw; //原片
    } else if (MaterialType == "MT02") {
      return AppStrings.of(context).SupplementaryMaterial; //辅料
    } else if (MaterialType == "MT03") {
      return AppStrings.of(context).Hardware; //五金
    }
    return MaterialType ?? "";
  }
  String? CompanyId="";
  String? ShareType="";//分摊方式
  ///获取分摊方式名称
  String getShareTypeName(BuildContext context) {
    if (ShareType == "1") {
      return AppStrings.of(context).ShareType1; //平方分摊
    } else if (ShareType == "2") {
      return AppStrings.of(context).ShareType2; //单位分摊
    } else if (ShareType == "3") {
      return AppStrings.of(context).ShareType3; //金额分摊
    }
    return ShareType ?? "";
  }
  String? CompanyBank="";
  String? BankAccount="";
  String? TaxCode="";
  String? AdvanceOffsetMode="";
  String? AdvanceOffsetPercent="";
  String? AdvanceOffsetPercentFinal="";
  String? PaymentType="";
  @override
  fromJson(Map<String, dynamic> json) {
    // TODO: implement fromJson
    // super.fromJson(json); //fixme 先实现父类的
    Cptc = setGenericFromJson(json, 'Cptc', ContractPaymentTerms(), "");
    FileInfo =
        setGenericFromJson(json, 'FileInfo', <FileInfoBean>[], FileInfoBean());
    PriceUnitName = json['PriceUnitName']?.toString() ?? "";
    CompanyName = json['CompanyName']?.toString() ?? "";
    CompanyBankName = json['CompanyBankName']?.toString() ?? "";
    CarrierName= json['CarrierName']?.toString() ?? "";
    TaxcodeName= json['TaxcodeName']?.toString() ?? "";

    PaymentTerms= json['PaymentTerms']?.toString() ?? "";
    AdvancePercent= json['AdvancePercent']?.toString() ?? "";
    Advance= json['Advance']?.toString() ?? "";
    MinimumBalanceB= json['MinimumBalanceB']?.toString() ?? "";
    MinimumBalanceA= json['MinimumBalanceA']?.toString() ?? "";
    MidYearMonth= json['MidYearMonth']?.toString() ?? "";
    MidYearDay= json['MidYearDay']?.toString() ?? "";
    MidYearPercent= json['MidYearPercent']?.toString() ?? "";
    MidAccountMonth= json['MidAccountMonth']?.toString() ?? "";
    MidAccountDay= json['MidAccountDay']?.toString() ?? "";
    EndYearMonth= json['EndYearMonth']?.toString() ?? "";
    EndYearDay= json['EndYearDay']?.toString() ?? "";
    EndYearPercent= json['EndYearPercent']?.toString() ?? "";
    EndAccountMonth= json['EndAccountMonth']?.toString() ?? "";
    EndAccountDay= json['EndAccountDay']?.toString() ?? "";
    EndPayDay= json['EndPayDay']?.toString() ?? "";
    DatePay= json['DatePay']?.toString() ?? "";
    ReconciliationDate= json['ReconciliationDate']?.toString() ?? "";
    MaxPay= json['MaxPay']?.toString() ?? "";
    PaymentPercent= json['PaymentPercent']?.toString() ?? "";
    BeforeMonth= json['BeforeMonth']?.toString() ?? "";
    WFLogList = setGenericFromJson(json, "WFLogList", <WFLog>[], WFLog());
    if (WFLogList == null) {
      WFLogList = [];
    }
    logisticsContractList= setGenericFromJson(json, "logisticsContractList", <logisticsContractListBean>[], logisticsContractListBean());
    IsSave= json['IsSave']?.toString() ?? "";
    deletedLogisticsContractListId= json['deletedLogisticsContractListId']?.toString() ?? "";
    deletedFileListId= json['deletedFileListId']?.toString() ?? "";
    Id= json['Id']?.toString() ?? "";
    LContractCode= json['LContractCode']?.toString() ?? "";
    LOutCode= json['LOutCode']?.toString() ?? "";
    CarrierId= json['CarrierId']?.toString() ?? "";
    TransportType= json['TransportType']?.toString() ?? "";
    CreaterDateTime= json['CreaterDateTime']?.toString() ?? "";
    PriceUnit= json['PriceUnit']?.toString() ?? "";
    LinkMan= json['LinkMan']?.toString() ?? "";
    Telephone= json['Telephone']?.toString() ?? "";
    Address= json['Address']?.toString() ?? "";
    Email= json['Email']?.toString() ?? "";
    IsTax= json['IsTax']?.toString() ?? "";
    SuperelevationTaxRate= json['SuperelevationTaxRate']?.toString() ?? "";
    SealType= json['SealType']?.toString() ?? "";
    StatementDate= json['StatementDate']?.toString() ?? "";
    Status= json['Status']?.toString() ?? "";
    creater= json['creater']?.toString() ?? "";
    Scrapcompensation= json['Scrapcompensation']?.toString() ?? "";
    MaterialType= json['MaterialType']?.toString() ?? "";
    CompanyId= json['CompanyId']?.toString() ?? "";
    ShareType= json['ShareType']?.toString() ?? "";
    CompanyBank= json['CompanyBank']?.toString() ?? "";
    BankAccount= json['BankAccount']?.toString() ?? "";
    TaxCode= json['TaxCode']?.toString() ?? "";
    AdvanceOffsetMode= json['AdvanceOffsetMode']?.toString() ?? "";
    AdvanceOffsetPercent= json['AdvanceOffsetPercent']?.toString() ?? "";
    AdvanceOffsetPercentFinal= json['AdvanceOffsetPercentFinal']?.toString() ?? "";
    PaymentType= json['PaymentType']?.toString() ?? "";
    createrName= json['createrName']?.toString() ?? "";
  }

  @override
  instance() {
    // TODO: implement instance
    return LogisticsContractBean();
  }

  @override
  Map<String, dynamic> toJson() {
    // TODO: implement toJson
    // var map = super.toJson(); //fixme 先实现父类的
    var map = <String, dynamic>{};
    map["Cptc"] = Cptc;
    map["FileInfo"] = FileInfo;
    map["PriceUnitName"] = PriceUnitName;
    map["CompanyName"] = CompanyName;
    map["CompanyBankName"] = CompanyBankName;
    map["CarrierName"] = CarrierName;
    map["TaxcodeName"] = TaxcodeName;

    map["PaymentTerms"] = PaymentTerms;
    map["AdvancePercent"] = AdvancePercent;
    map["Advance"] = Advance;
    map["MinimumBalanceB"] = MinimumBalanceB;
    map["MinimumBalanceA"] = MinimumBalanceA;
    map["MidYearMonth"] = MidYearMonth;
    map["MidYearDay"] = MidYearDay;
    map["MidYearPercent"] = MidYearPercent;
    map["MidAccountMonth"] = MidAccountMonth;
    map["MidAccountDay"] = MidAccountDay;
    map["EndYearMonth"] = EndYearMonth;
    map["EndYearDay"] = EndYearDay;
    map["EndYearPercent"] = EndYearPercent;
    map["EndAccountMonth"] = EndAccountMonth;
    map["EndAccountDay"] = EndAccountDay;
    map["EndPayDay"] = EndPayDay;
    map["DatePay"] = DatePay;
    map["ReconciliationDate"] = ReconciliationDate;
    map["MaxPay"] = MaxPay;
    map["PaymentPercent"] = PaymentPercent;
    map["BeforeMonth"] = BeforeMonth;
    map["WFLogList"] = WFLogList;
    map["IsSave"] = IsSave;
    map["deletedLogisticsContractListId"] = deletedLogisticsContractListId;
    map["deletedFileListId"] = deletedFileListId;
    map["Id"] = Id;
    map["LContractCode"] = LContractCode;
    map["LOutCode"] = LOutCode;
    map["CarrierId"] = CarrierId;
    map["TransportType"] = TransportType;
    map["CreaterDateTime"] = CreaterDateTime;
    map["PriceUnit"] = PriceUnit;
    map["LinkMan"] = LinkMan;
    map["Telephone"] = Telephone;
    map["Address"] = Address;
    map["Email"] = Email;
    map["IsTax"] = IsTax;
    map["SuperelevationTaxRate"] = SuperelevationTaxRate;
    map["SealType"] = SealType;
    map["StatementDate"] = StatementDate;
    map["Status"] = Status;
    map["creater"] = creater;
    map["Scrapcompensation"] = Scrapcompensation;
    map["MaterialType"] = MaterialType;
    map["CompanyId"] = CompanyId;
    map["ShareType"] = ShareType;
    map["CompanyBank"] = CompanyBank;
    map["BankAccount"] = BankAccount;
    map["TaxCode"] = TaxCode;
    map["AdvanceOffsetMode"] = AdvanceOffsetMode;
    map["AdvanceOffsetPercent"] = AdvanceOffsetPercent;
    map["AdvanceOffsetPercentFinal"] = AdvanceOffsetPercentFinal;
    map["PaymentType"] = PaymentType;
    map["logisticsContractList"] = logisticsContractList;
    map["createrName"] = createrName;
    return map;
  }
}

///运输线路车辆信息
class logisticsContractListBean extends BaseBean{
  String? Id="";
  String? LContractCode="";
  String? StartAddress="";


  String? EndAddress="";
  String? Mileage="";
  String? PriceUnit="";

  String? Price="";
  String? SuperelevationSpec="";
  String? Superelevationfreight="";
  String? ValuationType="";
  @override
  fromJson(Map<String, dynamic> json) {
    // TODO: implement fromJson
    Id= json['Id']?.toString() ?? "";
    LContractCode= json['LContractCode']?.toString() ?? "";
    StartAddress= json['StartAddress']?.toString() ?? "";
    EndAddress= json['EndAddress']?.toString() ?? "";
    Mileage= json['Mileage']?.toString() ?? "";
    PriceUnit= json['PriceUnit']?.toString() ?? "";
    Price= json['Price']?.toString() ?? "";
    SuperelevationSpec= json['SuperelevationSpec']?.toString() ?? "";
    Superelevationfreight= json['Superelevationfreight']?.toString() ?? "";
    ValuationType= json['ValuationType']?.toString() ?? "";

  }

  @override
  instance() {
    // TODO: implement instance
    return logisticsContractListBean();
  }

  @override
  Map<String, dynamic> toJson() {
    // TODO: implement toJson
    var map = <String, dynamic>{};
    map["Id"] = Id;
    map["LContractCode"] = LContractCode;
    map["StartAddress"] = StartAddress;
    map["EndAddress"] = EndAddress;
    map["Mileage"] = Mileage;
    map["PriceUnit"] = PriceUnit;
    map["Price"] = Price;
    map["SuperelevationSpec"] = SuperelevationSpec;
    map["Superelevationfreight"] = Superelevationfreight;
    map["ValuationType"] = ValuationType;
    return map;
  }
}